#include <kongm.h>
#include "kgamedb.h"

KGameDB::KGameDB(QObject *parent) :
    QObject(parent)
{
    setMaster(false);

    // First of all check if database is loaded or created in QT
    igames = QSqlDatabase::database( "Games" );

    qDebug() << "Trying to open Games database.";

    if( !igames.open() )
    {
        qDebug() << "Database not loaded, trying to load new one.";
        igames = QSqlDatabase::addDatabase( "QSQLITE", "Games" );
        igames.setDatabaseName("games.kdb");

        if( !igames.open() )
        {
            qCritical() << "Unable to establish a database connection.\n"
                "KON Game Manager needs SQLite support. Please read\n"
                "KON documentation for more information.";

        }
    }

}

bool KGameDB::setMaster( bool master )
{
    ///@todo CHECK PERMISSIONS
    isMaster = master;
    return true;
}

